#include "mainform.h"

#include <QApplication>

#include <QSharedMemory>
#include <QMessageBox>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    static QSharedMemory *singleApp = new QSharedMemory("SingleApp");//创建“SingleApp”的共享内存块
    if(!singleApp->create(1))//创建失败，说明已经有一个程序运行，
    {
        QMessageBox::information(NULL,"tips","The program is already running");//弹出提示框 注意：该提示应该在 qApp->quit();之前，否则提示框将会一闪而过
        qApp->quit();//退出当前程序
        return -1;
    }

    MainForm w;
    //w.show();
    return a.exec();
}
